﻿using Glue;
using Xunit;

namespace GlueTests.AutoRelaterTests
{
    public class When_autorelater_is_overriding
    {
        private readonly Mapping<DomainPerson, GuiPerson> mapping;

        public class DomainPerson { public int Id { get; set; } }
        public class GuiPerson { public int Id { get; set; } }


        public When_autorelater_is_overriding()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
            mapping.RelateTowardsRight(domain=>domain.Id,gui=>gui.Id);
            mapping.AutoRelateEqualNames();
            
        }

        [Fact]
        public void Should_override_not_be_added_additionally()
        {
            Assert.Equal(1, mapping.Relations.Count);
        }

        [Fact]
        public void Should_override_the_first_added()
        {
            Assert.Equal(RelationDirection.TwoWays,mapping.Relations.Get(domain=>domain.Id,gui=>gui.Id).Direction);
        }
    }
}
